package com.example.hyg_veintype.view.guideDialog;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.example.hyg_veintype.R;
import com.example.hyg_veintype.base.baseadapter.BaseHolder;
import com.example.hyg_veintype.base.baseadapter.BaseRecyclerAdapter;
import com.example.hyg_veintype.view.guideDialog.data.GuideBean;

import java.util.List;


/**
 * @author: yyw
 * time: 2020/12/15 13:29
 * desc: 用户引导dialog vp适配器
 */
public class GuideVpAdapter extends BaseRecyclerAdapter<GuideBean> {


    public GuideVpAdapter(List<GuideBean> infos, Context context) {
        super(infos, context);
    }

    @Override
    public BaseHolder<GuideBean> getHolder(View v, int viewType) {
        return new MyHolder(v, context);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.veintype_item_guide;
    }

    public class MyHolder extends BaseHolder<GuideBean> {

        TextView tvIndex;
        TextView tvTitle;
        ImageView img1;
        ImageView img2;

        public MyHolder(View itemView, Context context) {
            super(itemView, context);
            tvIndex = itemView.findViewById(R.id.tv_index);
            tvTitle = itemView.findViewById(R.id.tv_title);
            img1 = itemView.findViewById(R.id.img1);
            img2 = itemView.findViewById(R.id.img2);
        }


        @Override
        public void setData(GuideBean data, int position) {
            tvIndex.setText(position + 1 + "");
            tvTitle.setText(data.getTitle());
            img1.setImageDrawable(ContextCompat.getDrawable(context, data.getImg1()));
            img2.setImageDrawable(ContextCompat.getDrawable(context, data.getImg2()));
        }
    }
}
